ScrollDir
By Paul S. McCarthy and Eric Sunshine
Copyright ã1995,1996 by Paul S. McCarthy and Eric Sunshine
February 9, 1996

Overview

This program demonstrates the use of MiscTableScroll object in eager mode by acting as a simple directory browser.  Basic operations such as open, delete, and change directory can be performed on the listed files and directories.

Notable Features

Eager Mode
This example uses an eager mode MiscTableScroll which creates and fills all cells immediately.  This differs from a lazy mode MiscTableScroll where the data-delegate is responsible for managing the cells.  Eager mode is useful for fairly small data sets and data sets for which data retrieval time is small.  Eager mode is usually easier to program than lazy mode.

Color
The example shows how cells can inherit color from the MiscTableScroll itself, as well as maintain their own colors independently.  Color swatches can be dragged from the Color Panel and dropped onto the browser window.  The background of the MiscTableScroll is set to the color of the dropped swatch.  All cells which inherit their color from the MiscTableScroll implicitly take the same background color.  All cells which have had their color set explicitly retain their own color.

The highlight directories switch on the browser window demonstrates that cells can maintain their own colors instead of inheriting them.  When toggled on the rows for directories are highlighted in a color independent of the MiscTableScroll.

Font
When the MiscTableScroll is first-responder, the Font Panel can be used to change its font.  Cells which inherit their font from the MiscTableScroll display the newly selected font.

Users Preferences
This program demonstrates how to save and restore the user's column order and width preferences.  Additionally, all other user preferences -- font, color, switch settings, and window size -- are also saved and restored.

Icon Display
One column in the browser displays the file's icon.  This demonstrates how to use icon columns in addition to text columns.

Sorting
A switch on the browser window controls whether or not rows are automatically sorted as columns are rearranged.  This demonstrates the very powerful built-in sorting capability of MiscTableScroll.  Sorting can be fine-tuned right in the nib file by adjusting the criteria on a column-by-column basis.  For instance, columns may contribute stringValue, title, intValue, tag, etc. to the row-wise comparisons.

Name Caching
NetInfo is notoriously slow.  Translation of user and group numbers into their text equivalents is sped up by caching the results of calls to getpwuid and getgrgid (both of which ultimately consult NetInfo).